from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
from sqlalchemy.orm import relationship

from ..db.base import Base, TimestampMixin

class Session(Base, TimestampMixin):
    """会话数据库模型"""
    __tablename__ = "sessions"

    id = Column(String, primary_key=True)
    user_id = Column(Integer, ForeignKey("users.id"))
    expires_at = Column(DateTime(timezone=True))

    # 关系
    user = relationship("User", back_populates="sessions")